import QRCode from '../../utils/weapp-qrcode.js';
import tool from "../../utils/tool.js";
import {
  request,
  BASEURL
} from '../../utils/request';
Page({
  data: {
    show: true,
    info: {},
    photoShow: false,
    goodsMnie:{},
    time:'',
    time2:'',
    tempfilepath:'',
    xing:5,
    count:''
  },
  onload: function(options){

  },



  onShow: function () {
    const uid = wx.getStorageSync('uid')
    if (uid) {
      this.setData({
        info: uid,
        photoShow: true
      })
      this.userInfo()
      this.teamCount()
    }
  },
// 暂未开通
ZanBtn(){
  wx.showToast({
    title: '暂未开发',
    icon:"none"
  })
},

tapHandler1:tool.throttle(function(e){
  this.tapHandler(e)
}),
  //生成海报
  async tapHandler(){
    //判断是否登录
    var uid = wx.getStorageSync('uid')
    if (!uid) {
      wx.navigateTo({
        url: '/pages/login/login',
      })
      return
    } else {
      var {openid} = wx.getStorageSync('uid')
      let res = await request({
        url: '/api/Wxapp/checkProp',
        method:"POST",
        data:{
          openid
        }
      })
      console.log(res.data)
      if(res.data.code==0){
        wx.showToast({
          title: '请先激活推广资格',
          icon:"none",
          duration:1500
        })
        return 
      }else{
        wx.navigateTo({
          url: '/pages/code/code',
        })
      }

    }
},
//关闭
onClose() {
this.setData({
  show: false
});
},
//个人中心接口
  async userInfo(){
    let {openid} = wx.getStorageSync('uid')
    let res = await request({
      url: '/api/Wxapp/userInfo',
      method:"POST",
      data:{
        openid
      }
    })
    console.log(res)
    let goodsMnie = res.data.data
    this.setData({
      goodsMnie,
      BASEURL
    })
  },

  // 团队人数
  async teamCount(){
    let {openid} = wx.getStorageSync('uid')
    let res = await request({
      url: '/api/Wxapp/teamCount',
      method:"POST",
      data:{
        openid
      }
    })
    console.log(res)
    let count = res.data.data
    this.setData({
      count
    })
  },
  //登录
  mineLogin() {
    //判断是否登录
    var uid = wx.getStorageSync('uid')
    if (!uid) {
      wx.navigateTo({
        url: '/pages/login/login',
      })
      return
    }
  },
  //收益
  earnings() {
    wx.navigateTo({
      url: '/pages/account/account',
    })
  },
  //业绩
  results() {
    //判断是否登录
    var uid = wx.getStorageSync('uid')
    if (!uid) {
      wx.navigateTo({
        url: '/pages/login/login',
      })
      return
    } else {
      wx.navigateTo({
        url: '/pages/results/results',
      })
    }

  },
  // 待发货 待收货 已完成
  orderDetail(e) {
    //判断是否登录
    var uid = wx.getStorageSync('uid')
    if (!uid) {
      wx.navigateTo({
        url: '/pages/login/login',
      })
      return
    } else {
      let {
        index
      } = e.currentTarget.dataset
      if (index == 1) {
        wx.navigateTo({
          url: '/pages/mineOrder/mineOrder?index=' + index,
        })
      } else if (index == 2) {
        wx.navigateTo({
          url: '/pages/mineOrder/mineOrder?index=' + index,
        })
      } else if (index == 3) {
        wx.navigateTo({
          url: '/pages/mineOrder/mineOrder?index=' + index,
        })
      }
    }
  },
    // 查看更多订单
    more() {
      //判断是否登录
      var uid = wx.getStorageSync('uid')
      if (!uid) {
        wx.navigateTo({
          url: '/pages/login/login',
        })
        return
      } else {
        wx.navigateTo({
          url: '/pages/mineOrder/mineOrder?index=' + 1,
        })
      }
    },

  //我的团队
  async bottomBtn(e) {
    //判断是否登录
    var uid = wx.getStorageSync('uid')
    if (!uid) {
      wx.navigateTo({
        url: '/pages/login/login',
      })
      return
    } else {
        wx.navigateTo({
          url: '/pages/team/team',
      })
    }

  },

  //收益明细 提现明细 提现明细
  mingxi(e) {
    console.log(e)
    let {
      index
    } = e.currentTarget.dataset
    //判断是否登录
    var uid = wx.getStorageSync('uid')
    if (!uid) {
      wx.navigateTo({
        url: '/pages/login/login',
      })
      return
    } else {
      if (index == 1) {
        wx.navigateTo({
          url: '/pages/withdrawal/withdrawal',
        })
      } else if(index == 2){
        wx.navigateTo({
          url: '/pages/results/results',
        })
      }else if(index == 3){
        wx.navigateTo({
          url: '/pages/earnings/earnings',
        })
      }else if(index == 4){
        wx.navigateTo({
          url: '/pages/privacy/privacy',
        })
      }else if(index == 5){
        wx.navigateTo({
          url: '/pages/service/service',
        })
      }else if(index == 6){
        wx.navigateTo({
          url: '/pages/statement/statement',
        })
      }

    }

  },










  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */


  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})